/**
  90°            [x, y]   ->    [y, n-1-x]
  180°           [x, y]   ->    [n-1-x, n-1-y]
  270°           [x, y]   ->    [n-1-y, x]
 * @param {number[][]} mat
 * @param {number[][]} target
 * @return {boolean}
 */
export var findRotation = function (mat, target) {
  if (!mat.length) return false
  const n = mat.length
  let [res0, res90, res180, res270] = [true, true, true, true]
  for (let i = 0; i < n; i++) {
    for (let j = 0; j < n; j++) {
      res0 = res0 && mat[i][j] === target[i][j]
      res90 = res90 && mat[i][j] === target[j][n - 1 - i]
      res180 = res180 && mat[i][j] === target[n - 1 - i][n - 1 - j]
      res270 = res270 && mat[i][j] === target[n - 1 - j][i]
    }
  }
  return res0 || res90 || res180 || res270
}
